﻿<Window x:Class="Invaders.View.InvadersPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Invaders.View"
        xmlns:viewmodel="clr-namespace:Invaders.ViewModel"
        mc:Ignorable="d"
        Title="Invaders" Name="window" Width="800" Height="700"  KeyDown="window_KeyDown">
    <Window.Resources>
        <viewmodel:InvadersViewModel x:Key="viewmodel" />
        <viewmodel:BooleanVisibilityConverter x:Key="visibilityConverter" />
    </Window.Resources>
    <Grid DataContext="{StaticResource viewmodel}">
        <Grid.RowDefinitions>
            <RowDefinition Height="80"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel HorizontalAlignment="Right" Margin="0,5,120,0">
            <TextBlock Text="{Binding Score}" HorizontalAlignment="Right" Margin="0,0,15,0"/>
            <TextBlock Text="{Binding Lives}" HorizontalAlignment="Right" Width="Auto" Height="20" >
            <Image Source="player.png" Stretch="Fill" Height="15" Width="20"/>
            </TextBlock>
            <Button x:Name="startButton"  Click="startButton_Click"
                Content="Start!" 
                HorizontalAlignment="Center"
                VerticalAlignment="Center"/>
        </StackPanel>

        <Border BorderBrush="Blue" BorderThickness="2" CornerRadius="10" Margin="5" Background="Black" 
                Grid.Row="1" x:Name="playArea" >
            <ItemsControl ItemsSource="{Binding Path=Sprites}" Margin="5">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <Canvas Background="Black" />
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Border>
        <StackPanel Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"
                    Visibility="{Binding GameOver, Converter={StaticResource visibilityConverter}}" >

            <TextBlock Grid.Row="1" Text="Game Over" VerticalAlignment="Center" 
                       FontFamily="Arial Narrow" FontSize="150"
                       Foreground="Yellow" FontWeight="ExtraBold" FontStyle="Italic"
                       Margin="0,0,0,60" 
                       />
            <Button Content="Start a new game" Background="Black"
                    HorizontalAlignment="Center" FontSize="30" Click="startButton_Click"/>
        </StackPanel>

        <TextBlock Grid.Row="1" Text="Paused" VerticalAlignment="Center" 
                   FontFamily="Arial Narrow" FontSize="60"
                   Foreground="Yellow" FontWeight="ExtraBold" FontStyle="Italic"
                   Margin="120,0,0,60" 
                   Visibility="{Binding Paused, Converter={StaticResource visibilityConverter}}" 
                   />
        <MediaElement x:Name="backmedia" 
              Source="Techno.mp3" LoadedBehavior="Manual" UnloadedBehavior="Stop"
              MediaEnded="Element_BackMediaEnded"
              Width="40" />
        <MediaElement x:Name="media" 
              Source="Gunshots.wav" LoadedBehavior="Manual" UnloadedBehavior="Stop"
              MediaEnded="Element_MediaEnded"
              Width="40" />
        <MediaElement x:Name="blastedPlayerMedia" 
              Source="tickingbomb.wav" LoadedBehavior="Manual" UnloadedBehavior="Stop"
              MediaEnded="Element_blastedPlayerMediaEnded"
              Width="40" />
        <MediaElement x:Name="blastedInvaderMedia" 
              Source="explosion1.wav" LoadedBehavior="Manual" UnloadedBehavior="Stop"
              MediaEnded="Element_blastedInvaderMediaEnded"
              Width="40" />
    </Grid>
</Window>
